#include<bits/stdc++.h>
using namespace std;
const int N=2e5+3;
int n,ct,tt,ls,t[N],w[N],a[N],b[N],vis[N];
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]!=a[i-1])
		{
			w[tt]=i-1;
			t[++tt]=i;
		}
	}w[tt]=n;ct=0;
	while(ct<n)
	{
		ls=0;
		for(int i=1;i<=tt;i++)
		{
			if(b[i])
			{
				continue;
			}
			printf("%d ",t[i]);
			ct++;vis[t[i]]=1;
			while(vis[t[i]])
			{
				t[i]++;
				if(t[i]>w[i])
				{
					b[i]=1;
					break;
				}
			}
			if(ls&&!b[i])
			{
				if(a[w[ls]]==a[t[i]])
				{
					b[i]=1;
					w[ls]=w[i];
				}
			}
			if(!b[i])
			{
				ls=i;
			}
		}printf("\n");
	}return 0;
}
